Solved

building bounding box from esri shapefile

Posted on 2010-11-19
15
1,165 Views
Last Modified: 2012-05-10
I have ESRI shapefiles from a gov source.  I want to grab bounding box coordinates, a best fit rectangle that circumscribes the geographical region.  I need to get the lat/long min/max values (all 4) into a csv.  Found this tool http://www.obviously.com/gis/shp2text/ but cant figure out how to use it.  
0
Comment
Question by:sbauch
  • 9
  • 5
15 Comments
 
LVL 37

Assisted Solution

by:TommySzalapski
TommySzalapski earned 250 total points
Comment Utility
Just parse through all the x,y coordinates in the shape file (use the info here http://en.wikipedia.org/wiki/Shapefile).
Skip the100 bytes for the header and then for each of the records look at all the X and Y values and calculate the max and min.
Or is that what you need help doing? What language do you code int?
0
 

Author Comment

by:sbauch
Comment Utility
Yeah exactly I don't code.  I built a drupal site using point and click, and I'm trying to do this to set up a geo taxonomy system without typing out all of my taxonomy terms and bounding boxes.  I also don't really understand the bounding box exactly.  Looking through the shp.xml file in a text editor I see this:

<geoBox esriExtentType="decdegrees">
                  <westBL Sync="TRUE">-74.257465</westBL>
                  <eastBL Sync="TRUE">-73.69945</eastBL>
                  <northBL Sync="TRUE">40.915808</northBL>
                  <southBL Sync="TRUE">40.495805</southBL>
                  <exTypeCode Sync="TRUE">1</exTypeCode>
            </geoBox>

but that's the only place where I see coordinates.  The shapefile I downloaded is for NYC boroughs, so my impression was that this file would have bounding box values for all 5 boroughs, whereas that looks like it might be the coordinates for a box that bounds all of NYC.
0
 
LVL 13

Expert Comment

by:Molnar István
Comment Utility
my idea is :
on this site is an online file converter:
http://www.gpsvisualizer.com/gpsbabel/
, you can convert the file to google earth kml file , then open the kml file in google map and modify the coordinates

hope it helps
0
 
LVL 37

Expert Comment

by:TommySzalapski
Comment Utility
Can you post the .shp file and the shp.xml file if they aren't super large or link to where you downloaded them would be better.
0
 
LVL 37

Expert Comment

by:TommySzalapski
Comment Utility
quicksilver, that's for waypoint files and such. I don't think it will work on .shp files.
0
 

Author Comment

by:sbauch
Comment Utility
link here:

http://www.nyc.gov/html/dcp/html/bytes/dwndistricts.shtml#bcd

I want to have a multiple level hierarchy, so I eventually need 2 csv files, one for borough bounds and one for whatever gov't label fits common neighborhood bounds best
0
 
LVL 37

Assisted Solution

by:TommySzalapski
TommySzalapski earned 250 total points
Comment Utility
Ah. This tool is exactly what you need
http://www.qarah.com/shapeviewer/

Give me a minute and I'll crack out the excel formulae you need.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 37

Assisted Solution

by:TommySzalapski
TommySzalapski earned 250 total points
Comment Utility
Okay I got it. Here is an Excel file that will get the data for you.
Open the .shp file in shape viewer and hit File->Export->Coordinates to Excel
Paste the data from that file to the shp sheet.
Then open the .dbf file and paste the data there on the dbf sheet.
Fill the formulas down (note they are array formulas so if you edit them use ctrl+shift+enter to confirm)
I stripped most of the data off the shp sheet because it was too large to the numbers in the sheet I am posting are not correct. You need to export the file and paste the data then the numbers will be right.

By the way. If you feel this deserves the full 500 points, please increase the point value of the question. Thanks. (I win a free t-shirt if I get enough points)
shp-bounds.xls
0
 

Author Comment

by:sbauch
Comment Utility
hmm I get this error when trying to export coordinates to excel:

Error: 5 - invalid procedure call or argument.
In: Form1.frm\Private Sub mnuExportToExcel_Click
At Line: 1

More than willing to paypal you $20 to do this for me. Is that allowed by EE's terms? I'm not a student
0
 
LVL 37

Assisted Solution

by:TommySzalapski
TommySzalapski earned 250 total points
Comment Utility
Okay, here you go.
If you want the big data files let me know and I'll upload them on DropBox and post you a link.
bounds.xls
0
 

Accepted Solution

by:
sbauch earned 0 total points
Comment Utility
Okay I was assuming that the resulting values would be in latitude longitude format. I guess I described what I was looking for incorrectly, but you definitely provided a very helpful answer. I have the .shp and see that you put the number of lines in what you posted, so I think I'll be able to emulate it.  Any ideas for whats next? Should I post a new question?
0
 
LVL 37

Expert Comment

by:TommySzalapski
Comment Utility
That first sheet I posted has all the formulas you'll need. You should see an 'Upgrade points' button and the top of the question.
0
 
LVL 37

Expert Comment

by:TommySzalapski
Comment Utility
After you get this closed hit 'Ask a related question' to ask how to convert from X,Y to lat/lon. It will notify me. I think I have an idea.
0
 
LVL 37

Expert Comment

by:TommySzalapski
Comment Utility
Or just do it now.
0
 

Author Closing Comment

by:sbauch
Comment Utility
how do I change # of points?
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now