3

I'm trying to build a heatmap of crime locations as part of a big data solution. My inputs are street names that I must map to geo coordinates. I know java and have downloaded several gis toolsets but have no experience with GIS at all.

I found an ArcGIS dataset that seems to have all street names for the state in question and have managed to export it to .csv format as follows

"FCC,C,3","RDNAME,C,60","FRADDL,N,11,0","TOADDL,N,11,0","FRADDR,N,11,0","TOADDR,N,11,0","ZIPL,N,5,0","ZIPR,N,5,0","FEDIRP,C,2","NAME,C,30","FETYPE,C,4","FEDIRS,C,2","FEDIRP2,C,2","NAME2,C,30","FETYPE2,C,4","FEDIRS2,C,2","FEDIRP3,C,2","NAME3,C,30","FETYPE3,C,4","FEDIRS3,C,2","FMCDL,N,5,0","FMCDR,N,5,0","COUNTYL,N,3,0","COUNTYR,N,3,0","NFC,N,2,0","RU_L,N,2,0","RU_R,N,2,0","LEGALSYST,N,2,0","PR,N,7,0","BMP,N,10,3","EMP,N,10,3","BPT,C,8","EPT,C,8","LRS_LINK,C,23","LENGTH,N,20,5","OID,N,13,0","VER,C,3"
A45, Federal Forest Road 4694,0,0,0,0,48763,48763,, Federal Forest Road 4694,,,,,,,,,,,87180,87180,69,69,0,1,1,0,5491232,0,0.314,83013877,83013878,54912328301387783013878,505.59898942,8301387708041,14a
A32,.TRUE. Dr SW,4699,4629,4698,4628,49544,49544,,.TRUE.,Dr,SW,,,,,,,,,82960,82960,81,81,7,4,4,5,443704,0,0.093,41019877,41035029, 4437044101987741035029,148.7904383145,4101987705219,14a
A32,0 27,0,0,0,0,49835,49835,,0 27,,,,O 27,,,,,,,26960,26960,41,41,7,1,1,3,1357703,0,0.16,21012040,21013908,13577032101204021013908,257.495040047,2101204009438,14a
A32,0 32,0,0,0,0,49835,49835,,0 32,,,,O 32,,,,,,,26960,26960,41,41,7,1,1,3,1357510,0,0.246,21013561,21012894,13575102101356121012894,396.278062758,2101356135998,14a

The problem is this doesn't contain geo coordinates in any format I recognize (decimal lat and lng coordinates).

I do have QGIS downloaded and loaded that with the .shp file. Looks like that will do it but don't know how to proceed. Can someone please advise? All I need for now is a .csv file with street names and vectors with lat/lng end point coordinates.

1
  • You mention an "ArcGIS dataset". Which format are you referring to with that (.shp, .gdb etc) - Assuming .shp as it's in the question title. Have you got access to ArcGIS? Are you also/alternatively looking for a solution using QGIS?
    – Phil G
    Commented Nov 12, 2016 at 15:25

2 Answers 2

7

Shapefiles only store attribute data in the dbf file, the other files associated with the shapefile contain the geometry data and metadata in binary and text formats. The shapefile binary format is open, but you are on a good track using QGIS to do the conversion rather than reinventing the wheel.

In QGIS,

  • right-click on the shapefile in the layers panel and choose "Save As".
  • At the top, choose "CSV" from the "Format" drop-down.
  • Set the file name in the "Save As" text box.
  • Under CRS, choose EPSG:4326.
  • Under layer options at the bottom, make sure "Geometry" is set to "AS_XY" if you have point coordinates. For a line, you likely want "AS_WKT".

These steps, together with the 4326, should get you long-lat coordinates. The line coordinates will be in well-known text format (WKT), as described here.

There is a whole lot more that can be said about coordinate systems, ways to store data, etc., but this should be a starting point for you.

enter image description here

3
  • You solution seemed to work, but the generated csv is exactly the same as what I posted (except for simplified header line). Still don't see lat/lng geocoords there. Please advise.
    – Bradjcox
    Commented Nov 12, 2016 at 16:36
  • 1
    @Bradjcox Sorry about that - the instructions were for points and you have lines. I have edited the answer for lines. Does that work any better? Commented Nov 12, 2016 at 16:49
  • You should be able to parse the first and last long-lat coordinates of a line from the WKT as the first and last pairs of coordinates if that is what you need. The pairs are separated by spaces, while nodes on the line are separated by commas. Commented Nov 12, 2016 at 16:55
1

You can calculate the x and y coordinates in Arcmap.

  1. Open ArcMap and add the shapefile in it.
  2. right click to the shapefile in TOC (Table of Content) and click Open Attribute Table
  3. Create two fields named x and y in double format
  4. Right click to x field and select Calculate Geometry ( calculate x coordinates). for y field calculate y coordinates.
  5. export data to csv

another and very simple solution is using Add xy Coordinates tool in Data management toolS of ArcGIS.

enter image description here

I assumed that your data type is point

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.