GPSFileDepot Forums

General Category => Map Making Support => Topic started by: Seldom on December 16, 2011, 09:04:01 AM

Title: Data Search and Replace Question
Post by: Seldom on December 16, 2011, 09:04:01 AM
I posted this at the GM group and it still hasn't had an answer, so I'm hoping somebody here may be able to help me out. 

I have 5000 roads named 30???.  I'd like to rename them all ???, which should reflect the actual signage for the roads.  If I do a search and replace in GM and put ??? in the replace string I get 5000 roads named "???", not the numbers I want to remain.  Is there a wild card format that would permit this?
Title: Re: Data Search and Replace Question
Post by: Boyd on December 16, 2011, 09:32:29 AM
Not sure that I understand what you want, but powerful though the Globalmapper search feature is, I often find it can't do something I want. In that case, I export a shapefile and use FileMaker Pro to massage the .dbf.
Title: Re: Data Search and Replace Question
Post by: Seldom on December 16, 2011, 09:43:55 AM
I tried this in MSAccess, and couldn't figure it out there either.  I'm thinking the easiest solution would be to open it in OpenOffice subtract 30,000 from all the values and save it as a DBF.

Title: Re: Data Search and Replace Question
Post by: -Oz- on December 16, 2011, 10:40:12 AM
Load them into PostGIS and then do a SQL query where name=right(name,3) and it'll change all the names to just be the left-most 3 characters.
Title: Re: Data Search and Replace Question
Post by: Seldom on December 16, 2011, 01:25:23 PM
This is my first attempt with PostGreSql.  When I run the following batch file (copied from Oz's Hydrography tutorial) I get a "DBF file cannot be opened" message and an empty roads.sql file in my dixieNFRoads folder.


path="c:\program files (x86)\postgresql\9.0\bin\";%path%
shp2pgsql.exe "c:\maps-homemade\data\ut\ut forests\dixie\dixieNFRoads\Roads.shp" Roads>roads.sql
pause
Title: Re: Data Search and Replace Question
Post by: -Oz- on December 16, 2011, 01:50:33 PM
Do you have the file open in Global Mapper or any other program that may have locked the file?
Title: Re: Data Search and Replace Question
Post by: Seldom on December 16, 2011, 02:56:14 PM
I just re-booted and got the same error message.  If the file's locked, I don't know where to look for a lock file.  That command line should work for PostGreSql 9.0 shouldn't it?
Title: Re: Data Search and Replace Question
Post by: maps4gps on December 17, 2011, 03:50:27 AM
I get that message with some software if I changed the file to 'read-only' to keep from accidentially deleting it.
Title: Re: Data Search and Replace Question
Post by: Seldom on December 17, 2011, 09:20:09 AM
The "read only" box was not set. 

I've actually got the PostGIS-GUI plug in installed in pgAdmIII and I've successfully imported using the GUI.  I got an error message when I tried to import the shapefile until  I copied the PostGIS database to a new database and used the plugin to import to that.  That created 3 tables, Roads, Geometry Columns, and Spatial Ref Sys, with no error messages.

I can view the column I want to change, but haven't figured out yet how to make Oz's query work.  I get an "unexpected character" message at the start of the query.  Guess I'll have to learn some SQL.

Also need to figure out how to export the finished product to DBF.  After the import, I can't find a "roads.sql" anywhere on my C: drive.
Title: Re: Data Search and Replace Question
Post by: maps4gps on December 17, 2011, 10:36:22 AM
OZ's code was for a character field.  Are all the entries numeric? 
If so, GM would have made the field numeric if it created the .dbf file.
Title: Re: Data Search and Replace Question
Post by: -Oz- on December 17, 2011, 03:39:29 PM
My tutorial has the export commands.
Title: Re: Data Search and Replace Question
Post by: Seldom on December 17, 2011, 05:17:02 PM
Quote from: -Oz- on December 17, 2011, 03:39:29 PM
My tutorial has the export commands.

I just reviewed your PostgreSQL tutorial.  When I downloaded PostgreSQL the version available was 9.1, and PostGIS 1.5 was the only Spatial Extension.  Also, when I built the database, the only character set I could select was UTF8 (also in the template).  If I tried to select WIN1252 I got an error saying that I had to match the template.
Title: Re: Data Search and Replace Question
Post by: -Oz- on December 17, 2011, 06:57:19 PM
That shouldn't change the commands.  Did you try this?
pgsql2shp  -f "C:\your_map_directory\transportation\table.shp" -u postgres -p postgis table
Title: Re: Data Search and Replace Question
Post by: Seldom on January 13, 2012, 04:11:05 PM
Finally got everything working.  The PostGreSQL installation has two top level folders, 9.0 and 9.1.  Both of those folders have a BIN subfolder which contains shp2pgsql.exe and pgsql2shp.exe.  However only the 9.1\BIN contains all the DLLs necessary for them to run.  Also, I was trying to run it from a remote directory via a batch file by adding 9.1\BIN to the path.  Didn't work but when I ran it from the 9.1\BIN directory it did.

Are there any native viewers to view the geometry (like GM), or do I have to export it back to shapefiles to see it?.