Another question about shapefiles

Stephen Woodbridge woodbri at SWOODBRIDGE.COM
Tue Nov 16 15:33:39 EST 2004


Joseph,

I am out of town with limited access so make sure this goes to the list so
other can help with it.

Joseph Norris said:
> Steven,
>
> Some observations.
>
> When I do a shpdump of my current California file I get 69 shapes - I also
> get 69 records in the dbf file a county record for each county in
> California.
> However in the file that I am reading zips for California there are over
> 1500 lines a line with zip->lat long relation in California.
>
> How do I reconcile the shape/dbf with 69 records to a dbf file that I
> reconstruct from the current dbf.  Do I add som 1500+ records to it and
> then
> do I need to build that many shapes in the copied California shape file?
> Or
> will the  mapserver understand this.

What makes you think that you need to have a polygon layer with 69
counties reconcile to a point layer 1500+ zipcode points? The are just
different layers that should be rendered differently and therefore should
be different data files and have different layer definations.

I have 50+ layers in most of my mapfiles. This covers different data
layers and different rendering styles at different zoom scales, etc.

> In addition I took my zip->lat/long file for California and created
> shape/dbf files for this file - not sure what I use polygon, point?

It is point data so you had better have created it as POINT type shapefile.

> Then I added a layer to my map file pointing at this new cal_zip shape
> file.

See mapfile markups below.

-Steve

> As follows:
>
>   LAYER
>     NAME "california"
>     TYPE POLYGON
>     DATA "california"                         my current California shape file
>     STATUS DEFAULT
>     CLASS
>         COLOR 225 225 185
>     END
>   END
>
>   LAYER
>     NAME "cal"
>     TYPE POINT
>     DATA "cal"            # <<< is this right or "cap_zip"???
>     STATUS DEFAULT                    my new cal_zip shape file
>     CLASS
>         COLOR 0 0 51
          SYMBOL 0          # ADD this; default circle symbol
          SIZE 5            # Add this to make it bigger
>     END
>   END
>
> Nothing is still showing. I would hope to see even some points in the
> file.
>
> Am I being clear - or have I missed the point totally.
>
>
> #Joseph Norris (Perl - what else is there?/Linux/CGI/Mysql) print @c=map
> chr
> $_+100,(6,17,15,16,-68,-3,10,11,16,4,1,14,-68,12,1,14,8,-68,4,-3,-1,7,1,14,-
> 68,-26,11,15,1,12,4,-68,-22,11,14,14,5,15,-90);
>
> -----Original Message-----
> From: UMN MapServer Users List [mailto:MAPSERVER-USERS at lists.umn.edu]On
> Behalf Of Stephen Woodbridge
> Sent: Monday, November 15, 2004 10:13 AM
> To: MAPSERVER-USERS at lists.umn.edu
> Subject: Re: [UMN_MAPSERVER-USERS] Another question about shapefiles
>
> So if I understand correctly what you really want to do, is to geocode you
> database records with a lat/lon based on there zipcode. Then you want to
> present the database data as a layer of points based on this lat/lon
> value.
>
> If so then you should write a script to add lat, lon columns to your
> database and then for every record in the database populate the lat, lon
> based on the zipcode. If you load the zipcode, lat, lon as a new table you
> can dothis on the fly with a join.
>
> Regardless if I understand what you are asking for, youdon't need to
> create a shape layer from the zipcode data and even if you did, you would
> then be able to display the zipcodes as labels at the zipcode points but
> you would have no way to display the mysql data at the respective points.
>
> Hope this makes sense.
>   -Steve
>
> Joseph Norris said:
>> Steve,
>>
>> Thanks for this information.  I understand this.  However here is my
>> situation.  I have a shapefile of California.  It has its dbf file.
>>
>> This is a sample:
>>
>> 0.859846443800379:5.7057500729921:50:49:06:053:Monterey:06:County
>> 1.25622233242418:5.28286812594892:51:50:06:107:Tulare:06:County
>>
>>
>> I have another text file of zip codes with lat/long codes.
>>
>> "01","35004","AL","ACMAR",86.51557,33.584132,6055,0.001499
>> "01","35005","AL","ADAMSVILLE",86.959727,33.588437,10616,0.002627
>> "01","35006","AL","ADGER",87.167455,33.434277,3205,0.000793
>> "01","35007","AL","KEYSTONE",86.812861,33.236868,14218,0.003519
>> "01","35010","AL","NEW SITE",85.951086,32.941445,19942,0.004935
>> "01","35014","AL","ALPINE",86.208934,33.331165,3062,0.000758
>>
>>
>> I have the whole US - so I have California.
>>
>> What I am trying to accomplish is to layer the zip code data on top of
>> California an by that read a Mysql user table and by zip code place a
>> symbol
>> where these users are located.
>>
>> I am doing all of this from a ESRI background that would have made this
>> an
>> easier via the GUI but not as much fun and definitely not Open Source.
>>
>>
>>   BTW - I am doing all of this as proof of concept so that my company
>> will
>> get into GIS as an extension of  one of the best Open Source  content
>> management systems I have ever worked on - OK - enough of that - but it
>> is
>> a
>> really well designed product.
>>
>> #Joseph Norris (Perl - what else is there?/Linux/CGI/Mysql) print @c=map
>> chr
>>
> $_+100,(6,17,15,16,-68,-3,10,11,16,4,1,14,-68,12,1,14,8,-68,4,-3,-1,7,1,14,-
>> 68,-26,11,15,1,12,4,-68,-22,11,14,14,5,15,-90);
>>
>> -----Original Message-----
>> From: Stephen Woodbridge [mailto:woodbri at swoodbridge.com]
>> Sent: Monday, November 15, 2004 4:12 AM
>> To: Joseph Norris
>> Cc: MAPSERVER-USERS at LISTS.UMN.EDU
>> Subject: Re: [UMN_MAPSERVER-USERS] Another question about shapefiles
>>
>> Joseph,
>>
>> In the C interface I think you can open a file in mode "rb+" which will
>> allow you to read/write, BUT in general practice I would open the file
>> for read, copy it record by record, and then add any new data to the
>> file. Otherwise you run the risk of damaging your original file.
>> Typically if you need to do this via a multi-user interface, like a web
>> form you need to edit a database and not a shapefile as this library has
>> not locking and it WILL get trashed.
>>
>> -Steve
>>
>> Joseph Norris wrote:
>>
>>> Stephen,
>>>
>>> These are really great - I was able to build my shape file from zip
>>> file
>>> very easily.  Now the question is - and I have experimented.
>>>
>>> I see in the Shapelib docs I see that I can open a shapefile that
>>> already
>>> exists.  Can I then read another file of points and the put these
>>> points
>> on
>>> the original shape?
>>>
>>> No matter what I do I am getting errors back.   I can only find
>>> examples
>> of
>>> code in the pod for the module.
>>>
>>> Thanks for all your help.
>>>
>>> #Joseph Norris (Perl - what else is there?/Linux/CGI/Mysql) print
>>> @c=map
>> chr
>>>
>>
> $_+100,(6,17,15,16,-68,-3,10,11,16,4,1,14,-68,12,1,14,8,-68,4,-3,-1,7,1,14,-
>>> 68,-26,11,15,1,12,4,-68,-22,11,14,14,5,15,-90);
>>>
>>> -----Original Message-----
>>> From: UMN MapServer Users List [mailto:MAPSERVER-USERS at lists.umn.edu]On
>>> Behalf Of Stephen Woodbridge
>>> Sent: Sunday, November 14, 2004 6:14 PM
>>> To: MAPSERVER-USERS at lists.umn.edu
>>> Subject: Re: [UMN_MAPSERVER-USERS] Another question about shapefiles
>>>
>>> Joseph,
>>>
>>> Check out perl modules:
>>>
>>> Geo::ShapeFile
>>> Geo::Shapelib
>>> XBase
>>>
>>> These are handy modules for working with shapefiles and the DBF
>>> attributes file. I write scripts all the time for creating, reading and
>>> manipulating shapefiles. When I need more performance I usually use the
>>> shapelib library and C code.
>>>
>>> -Steve
>>>
>>> Joseph Norris wrote:
>>>
>>>>I have a US zip file containing zip codes and associated lat/long
>>>>information.  Can I convert this to points on a shapefile?
>>>>
>>>>#Joseph Norris (Perl - what else is there?/Linux/CGI/Mysql) print
>>>> @c=map
>>>
>>> chr
>>>
>>>
>>
> $_+100,(6,17,15,16,-68,-3,10,11,16,4,1,14,-68,12,1,14,8,-68,4,-3,-1,7,1,14,-
>>>
>>>>68,-26,11,15,1,12,4,-68,-22,11,14,14,5,15,-90);
>>>>
>>>
>>>
>>
>>
>
>
>
>



More information about the mapserver-users mailing list