More projections with ogr2ogr? - gis

I'm new to using ogr2ogr and have been wanting to reproject an ESRI Shapefile to NAD83 State Plane Washington North Projection (EPSG:32148) from WGS84.
Ive gotten it to reproject to NAD83 but I can't get it use a Projected Coordinate System. Does it only project Geographic Coordinate Systems?
If that is the case is there another library that will project PCS?

Using ogr2ogr options you can reproject the shapefile. Here I have run this command in terminal which gives the desired output.
Traffic shp was in WGS48 EPSG:32643 reference system. After running this command I got NAD83 EPSG:32148 projection.
ogr2ogr -f "ESRI Shapefile" -t_srs EPSG:32148 -s_srs EPSG:32643 'output.shp' 'trafic.shp'
Hope this will help.

Related

QGIS: all my points end up in the Atlantic Ocean

I'm following the tutorial guides in QGIS webpage, but I can't correctly import the dataset from the .csv file in the guide.
Here you can download the .csv file
Here you can download the shape .shp file
I imported the shp just by double clicking on it inside of QGIS
I pressed ctrl+L to open the delimited text layer window
from there i selected the .csv file using x as longitude and y as latitude
Here the result
Wrong point localization
What I did
The latitude and longitute coordinates look correct in the .csv file
I copied a location coordinates from the world map (ireland in my case) and I created a test .csv file with those coordinates. When import the csv file in my project it is placed in the atlantic Ocean and not in Ireland.
Is this a bug? I really can't understand what is happening.
As you can see the points are relatively well distributed, that means the original information is correct but there is something that has to do with the scale of the points that does not work (even tho coordinates are not ambiguous)
You will need to know a few things.
1.If the files you are using have coordinates systems assigned to them.
I am unsure about shp files as i deal mainly in Mesh Datasets and Rasters.
I do know that the CSV coordinates or Text file coordinates if they are GPS values ie:Lat Long have to be saved into a co-ordinates system value and that the QGIS project has to use the same coordinate system. The system uses the GPS coordinates to place the points accurately on the QGIS map. My Method is to use a site like bbox and use my Coordinates system of choice and record these Lat Long values into .CSV and then copy the same CRS settings from bbox within QGIS project then the shp and or imported files end up placed correctly when you load the imported text file layer or shp file. Also file formatting is important for text files like you have ie:CSV. If you set the CRS within the QGIS project if the layer you import in is from another CRS QGIS will automatically change this to the CRS you have set. If you do not have geographic information setout correctly you will have the problem you have now also another problem is if the file does not contain CRS information at all.
But from what you are telling us this looks like a CRS mismatch problem.
2.What the coordinates system is for the files you have ie:epsg 4326 or 3857 these are two very different different systems that can drastically alter the placement of your points.
3.If they dont have a coordinate system assigned to them then you will need to assign one and use this same coordinates system within QGIS project before you import in the files. .
4.If the files do contain coordinate systems references then in QGIS you will need to set the project CRS system to the same as the files you have. This will apply the CRS to all layers you add to this project weather they are vectors, mesh, rasters and or base layers.
Good luck.

How to create terrain files with points in Cesium?

I have a DEM file with XYZ points (file sample image), and I want to use it to create terrain in Cesium with it. I tried to translate it to GeoTiff by ArcMap, but it is not supported by cesium terrain builder.
How could I create terrain files with points in Cesium?
Cesium is able to consume Quantized Mesh tiles but not GTIFF or XYZ directly.
First, you will have to convert your XYZ file to e.g. GTIFF and transform it to WGS84 coordinate reference system. Both can be done using gdal.
Second, convert your transformed GTIFF files to quantized-mesh format.
I created a Docker image for that purpose. Check out the Github page of tumgis/cesium-terrain-builder-docker for a detailed documentation of the entire process.
Finally, you will need a service like CesiumTerrainServer to serve the tiles to a Cesium application.

Netlogo and GIS extension unsupported projection file

I am trying to import my ARCGIS Pro project to Netlogo and I am getting this error.
Extension exception: unsupported projection 'Mercator_Auxiliary_Sphere'
error while observer running GIS:LOAD-DATASET
called by procedure SETUP-MAP
called by Button 'setup-map'
How can I fix this issue?
First, go to the NetLogo User Manual section on the GIS extension. In the documentation for the primitive gis:load-coordinate-system, you will find a list of the projections that the extension can use. You will see that it can use several Mercator projections but not yours. So ideally you can fix this by going back to the GIS and saving your shapefile in one of the projections that NetLogo uses.
(I know almost nothing about GIS but: the GIS technician I work with often saves shapefiles for me in the Lambert_Conformal_Conic projection, while the GIS extension accepts only the Lambert_Conformal_Conic_2SP projection. We have learned to trick NetLogo by editing the shapefile’s .prj file to change the text "Lambert_Conformal_Conic" to "Lambert_Conformal_Conic_2SP". That makes the GIS extension think that we're using one of its projections, and it works. You could try this trick to tell NetLogo you're using one of the Mercator projections.)

I can't seem to plot latitude and longitude points after I've added a shapefile. What went wrong?

I am trying to add a shapefile that is a map of Manhattan wards and then plot some latitude-longitude data points over this map. I'm new to ArcMap and GIS in general.
Here is exactly what I am doing:
I have a shapefile that shows Manhattan wards when I "Add Data" it into ArcMap. I then go to Geoprocessing -> ArcToolbox -> Data Management Tools -> Projections and Transformations -> Define Projection. I then input my .shp file and select NAD 1983 State Plane New York Long Isl FIPS 3104 (US Feet) for the coordinate system. After I do this, my shapefile displays just fine.
I then "Add Data" a .csv file which contains addresses and the latitude and longitude for these addresses. I then right-click on this layer and select "Display XY Data...". I then make the "X Field" latitude and the "Y Field" Longitude and use the same coordinate system as mentioned above. However, the points never display. I still only see the wards shapefile displayed. Both layers are present in the Layers menu, but only one is actually being displayed.
Alternatively, if I restart ArcMap and add the points first and display the XY data, I see that the points are displayed. After I add the shapefile, the shapefile does not display. I only see the points. It seems I can always display one thing but not the other.
Any thoughts on why this is happening?
I am using ArcMap version 10.2.0.3348 on a Windows OS.
I assume you are trying to overlay different spatial reference systems without telling arcmap which ones you use, so it cant reproject them to fit together.
When you say "latitude" and "longitude" you normally mean a geographic coordinate system like WGS84. Whilse X and Y often refer to a projected coordinate system like NAD. You defined NAD for both layers...I think you should define a geographic coordinate system for your CSV File, if it really contains geographic coordinates.
ArcMap uses the spatial reference system of the first layer which is added as the display SRS (you can change this afterwards for sure), thats why you saw your shapefile first and after restart and adding the points saw the points first.
If every layer has its SRS defined correctly, ArcMap will reproject them automatically to fit your display SRS. If you define the wrong SRS for one layer, Arcmap will do nothing for sure, because there is no need to reproject a NAD layer to NAD (although the coordinates have a completely different value domain and your points get drawed somewhere else....check this by right clicking on the CSV layer and "Zoom to Layer (extend)".
To make it more complicated: Because NAD83 and WGS84 rely on different geodetic datums, you have to transform. You find a predefined set of transformation parameters when you right click on "layers" in the "table of contents" on the left and select "properties". On the "coordinate system" sheet you see the "Transform" Button where you can select the transformation parameters which should be use to get from NAD83 to WGS84 and vice versa. A more detailed description can be found at this GIS SE

Best way to overlay an ESRI shapefile on google maps?

What is the best way to overlay a shapefile in Google Maps?
After some reading suggests that, converting shapefile into KML and overlaying KML in Google map is an option. If that is the case, how do I convert a shapefile into KMLs?
I believe there would be a few open source tools available for this conversion. Can anyone point to a tool to covert a shapefile to KML without any loss of data?
I like using (open source and gui friendly) Quantum GIS to convert the shapefile to kml.
Google Maps API supports only a subset of the KML standard. One limitation is file size.
To reduce your file size, you can Quantum GIS's "simplify geometries" function. This "smooths" polygons.
Then you can select your layer and do a "save as kml" on it.
If you need to process a bunch of files, the process can be batched with Quantum GIS's ogr2ogr command from osgeo4w shell.
Finally, I recommend zipping your kml (with your favorite compression program) for reduced file size and saving it as kmz.
as of 12.03.2019 FusionTables is no more...
Import the Shapefile into Google FusionTables ( http://www.google.com/fusiontables ) using http://www.shpescape.com/ and from there you can use the data in a number of ways, eg. display it using GoogleMaps.
I would not use KML. Instead, use GeoJSON which you can natively consume in Google Maps API now. It is a newer feature that didn't exist from the original responses.
In any case, simply open the SHP file in Quantum GIS, and then you can output it in any format you like (KML, GeoJSON).
If you are using Google Maps for Work, I found a premium extension that handles loading shapefiles directly where you can just connect direct to the shapefile that you generate from ESRI. I did a search on the CMaps site and found this snippet which loaded US by state shapefile: https://gmapsplugin.net/cmapsanalytics/assets/shapes/usstates.shp
var cMap = new centigon.locationIntelligence.MapView();
cMap.key([your_api_key]);
cMap.layerNames(["Basic Shapes"]);
cMap.dbfKeys([['Alabama','Alaska','Arizona','Arkansas','California','Colorado','Connecticut','Delaware','District of Columbia','Florida','Georgia','Hawaii','Idaho','Illinois','Indiana','Iowa','Kansas','Kentucky','Louisiana','Maine','Maryland','Massachusetts','Michigan','Minnesota','Mississippi','Missouri','Montana','Nebraska','Nevada','New Hampshire','New Jersey','New Mexico','New York','North Carolina','North Dakota','Ohio','Oklahoma','Oregon','Pennsylvania','Rhode Island','South Carolina','South Dakota','Tennessee','Texas','Utah','Vermont','Virginia','Washington','West Virginia','Wisconsin','Wyoming']]);
cMap.userShapeKeys([['Massachusetts','Minnesota','Montana','North Dakota','Hawaii','Idaho','Washington','Arizona','California','Colorado','Nevada','New Mexico','Oregon','Utah','Wyoming','Arkansas','Iowa','Kansas','Missouri','Nebraska','Oklahoma','South Dakota','Louisiana','Texas','Connecticut','New Hampshire','Rhode Island','Vermont','Alabama','Florida','Georgia','Mississippi','South Carolina','Illinois','Indiana','Kentucky','North Carolina','Ohio','Tennessee','Virginia','Wisconsin','West Virginia','Delaware','District of Columbia','Maryland','New Jersey','New York','Pennsylvania','Maine','Michigan','Alaska']]);
cMap.labels([['Massachusetts','Minnesota','Montana','North Dakota','Hawaii','Idaho','Washington','Arizona','California','Colorado','Nevada','New Mexico','Oregon','Utah','Wyoming','Arkansas','Iowa','Kansas','Missouri','Nebraska','Oklahoma','South Dakota','Louisiana','Texas','Connecticut','New Hampshire','Rhode Island','Vermont','Alabama','Florida','Georgia','Mississippi','South Carolina','Illinois','Indiana','Kentucky','North Carolina','Ohio','Tennessee','Virginia','Wisconsin','West Virginia','Delaware','District of Columbia','Maryland','New Jersey','New York','Pennsylvania','Maine','Michigan','Alaska']]);
cMap.polyDataSources([centigon.locationIntelligence.CMapAnalytics.DATA_PROVIDERS.SHAPE_DATAPROVIDER]);
cMap.layerTypes([centigon.mapping.Layer.TYPE.POLY]);
cMap.locations([["https://gmapsplugin.net/cmapsanalytics/assets/shapes/usstates.shp"]]);
cMap.panTo("USA");
cMap.zoomLevel(3);
Do you mean shapefile as in an Esri shapefile? Either way, you should be able to perform the conversion using ogr2ogr, which is available in the GDAL packages. You need the .shp file and ideally the corresponding .dbf file (which will provide contextual information).
Also, consider using a tool like MapShaper to reduce the complexity of your shapefiles before transforming them into KML; you'll reduce filesize substantially depending on how much detail you need.
Free "Export to KML" script for ArcGIS 9
Here is a list of available methods that someone found.
Also, it seems to me that the most efficient representation of a polygon layer is by using Google Maps API's polyline encoding, which significantly compresses lat-lng data. But getting into that format takes work: use ArcMap to export Shape as lat/lng coordinates, then convert into polylines using Google Maps API.
Just to update these answers, ESRI has included this tool, known as Layer to KML in ArcMap 10.X. Also, a Map to KML tool exists.
Simply import the desired layer (vector or raster) and choose the output location, resolution, etc. Very simple tool.
2018 already... I've found this fantastic online tool http://mapshaper.org/ to convert from ESRI shapefiles to SVG, TopoJSON, GeoJSON.
Here is the explanation of how to use it https://www.statsilk.com/maps/convert-esri-shapefile-map-geojson-format
Fast and straightforward! :)