Skip to content

Generating Lat Lon Points to load in

jasonlally edited this page May 15, 2012 · 1 revision

Method using ArcGIS 10

Not the only way to do this, but if you have ArcGIS, you can do some quick operations to get a series of random lat/lon points for your community. Here's how I did it using ArcGIS 10:

Preparing line segments (blocks)

  1. Pull down your census TIGER/Line files (you can start here http://www.census.gov/cgi-bin/geo/shapefiles2010/main). Alternatively, you may have local versions maintained by your city or you can grab Open Street Map data. TIGER/Line files are simple enough and you can grab them quickly by county.
  2. Load your shapefile into ArcMap
  3. These files will generally not be segmented by block, which is what you want. The easiest way to get a series of segmented road lines is to use the tool "Feature to Line" (http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001700000039000000)

Generating midpoints for each block

  1. Now you need a midpoint for each line segment. There are many ways to do this, including through scripting. The simplest way I found was to use XTools Pro "Convert Features to Points" tool under Feature Conversion. (XTools Pro is an extension for ArcGIS, the free version allows you to use the mentioned tool. Download here: http://www.xtoolspro.com/download.asp) XTools Pro Tools
  2. There is no midpoint function, so you have to generate 2 files. First, generate the endpoints so you'll have a point shapefile with every endpoint of each line segment. Then, generate 3 equidistant points so you'll have a shapefile with endpoints and midpoints.
  3. Using ArcMap's "Select by Location," you can now select all of the endpoints from your second shapefile created in the previous step by selecting all of the features that are identical to those in the first shapefile of enpoints.
  4. Now, open your attribute table for the shapefile of 3 equidistant points and invert your selection. Now all of the midpoints will be selected and you can export those to a separate shapefile.
  5. Now add 2 floating point fields called Lat and Lon
  6. Right click on Lat and select "Calculate Field Geometry" and generate the X Coordinate for that field
  7. Right click on Lon and select "Calculate Field Geometry" and generate the Y Coordinate for that field

Selecting a set of random midpoints to load into streetscore

  1. In your shapefile of midpoints, you can use a bit of Python to generate a random floating point number from 0 to 1.0. Start by adding a floating-point field called "RAND"
  2. Right click on the new field RAND and select "Field Calculator"
  3. Click the box "Show Code Block"
  4. Select the radio button for Python at the top of the window
  5. Enter the following into the code block: import numpy.random as R def getRandomValue(): return R.random()
  6. And enter this into the expression: getRandomValue()
  7. Select attributes by query iteratively until you get the number of points you'd like. For example, RAND < .01 got me about 250 points but this will vary based on your particular data.
  8. Finally, export these selected points to CSV and you have your import ready document for streetscore!