How can I make a shapefile of an CSV file with coordinates?
If you have FME (or the Data Interoperability Extension in ArcGIS) then the solution looks like this:
A CSV reader, 2DPointReplacer transformer, a PointConnector transformer (optional), and a Shape writer. There are some more examples on our FMEpedia knowledgebase.
Pros: Easy and visual. Also flexible (there are simple ways to handle data that is not just x/y but includes headers, etc) and with a much greater range of format support (not just CSV and Shape)
Cons: Not Free/Open-Source software. If this is a one-off project, or you already have one of the other solutions specified here, then it's probably not worth buying FME just for this one task.
2016 Since this question came up on my radar today, I'll add that the latest FME versions have a parameter in the CSV reader to specify which attributes are coordinates. That way you don't need the 2DPointReplacer any more (which is now renamed to the VertexCreator anyway!)
If you use QGIS, try this tutorial: http://qgis.spatialthoughts.com/2012/01/importing-spreadsheets-or-csv-files-to.html
The easiest and fastest way of doing it is probably with ogr
In the csv driver doc is an example syntax from csv to shape: http://gdal.org/ogr/drv_csv.html
ogr2ogr -f "ESRI Shapefile" shapefilename.shp PG:"host=host user=user dbname=databasename password=password" -sql "SELECT the_geom FROM tablename"
if you are PostgreSQL/PostGIS user, you can convert your bulk data as following:
1.Create a new table for your csv files.
2.Copy csv to newly created table.
COPY yourNewTableName (lat, long, name, other) FROM '/path/yourCSVfile.csv' CSV;
3.Now you have to create geometry column for your spatial data.
SELECT addgeometrycolumn('public','yourNewTableName ','the_geom',4326,'POINT');
4.Populating the geometry column from your lat, long with UPDATE function with GeometryFromText function of PostGIS.
UPDATE yourNewTableName SET the_geom = GeometryFromText('POINT('||lat||' '||long||')',4326);
5.The last thing, you can connect to QGIS for exporting format of shp or the following code:
pgsql2shp -s 4326 -W latin5 -f newSHP -h localhost -u username -P password yourdataBaseName "SELECT * FROM yourNewTableName"
and you can use How to convert PostGIS table to Shapefile in Python? or csv2shp (CSV to Shapefile Converter) tool for bulk converting...
i hope it helps you...
First, be certain there are "no" special characters or spaces in the column headings (the only exception is "underscore"). For example, if you have a name like "Borehole ID", change it to something like "BH_ID" or "BHID". Assuming you're using ArcMap, navigate to the .csv file (either in Catalog, or in the Catalog window in ArcMap), right mouse over your .csv file, select "Create Feature Class" ---- > and then "From XY Table". The image shown below is what you'll see next. Populate the "X Field" with your Easting column header and your "Y Field" with the Northing Column header. You can leave the "Z Field" blank unless you want to assign elevations to your points. Next, click on the area that says "Coordinate System of Input Coordinates". Here, you will assign the appropriate projection/datum/zone. Lastly (near the bottom) hit the folder and route to the appropriate directory on your computer or server, and name your new shapefile.
Although not Shape, another way to convert text-based X/Y coordinates to a spatial dataset is to load them into Google Fusion Tables. From there you can export them to a KML dataset.
I suggest this because whatever application you're going to use Shape in, it may also support KML natively. Many do.
Here's an arcpy-based solution.
"Takes a CSV as input, write a SHP as output" import arcpy import os csv_input = r"C:\path\to\input.csv" shp_output_dir = os.path.dirname(csv_input) temp_layer = os.path.splitext(os.path.basename(csv_input)) # == "input" # OP NOTE - you say "coordinates" and I assumed you meant WGS84 latitude/longitude. If not, this is NOT your projection WGS84_PROJ = "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]];IsHighPrecision" # OP NOTE - if the latitude/longitude fields aren't named as such you'll need to update this arcpy.MakeXYEventLayer_management(csv_input, "LATITUDE", "LONGITUDE", temp_layer, WGS84_PROJ) # OP note: this exports a feature to a directory as a shapefile. # You don't specify the name directly, it's just taken from the existing `temp_layer` name arcpy.FeatureClassToShapefile_conversion(temp_layer, shp_output_dir) arcpy.Delete_management(temp_layer) # clean up layer, for completeness
I'm sure there are lots of examples of how to do this. You can see how to do this in SpatiaLite (with both GUI and command line options) at http://www.gaia-gis.it/gaia-sins/spatialite-cookbook/html/impexp.html
Add your csv file in Table of Contents in ArcGIS Desktop. Right click on your data and go for Display XY Data. Selecet your X and Y field, also coordinate system. Then you have a visualization of your points. You can also right click and export your visualization as shapefiles.
The reason I prefer this method instead of converting to shapefiles right away is this way you can preview your file before actually convert and save it to your disk, with potential errors.