Tag Info

Hot answers tagged

36

GDAL has a nice convenient interface to the PROJ4 library. If you are confident with Python, using the GDAL Python bindings, if you import the osr classes you will have very convenient methods for reading and exporting projection representations to a variety of formats like PROJ4, WKT, Esri .PRJ. For example this script will convert your .PRJ file of your ...


15

The geopy module provides the Vincenty formula, which provides accurate ellipsoid distances. Couple this with the wkt loading in Shapely, and you have reasonably simple code: from geopy import distance from shapely.wkt import loads line_wkt="LINESTRING(3.0 4.0, 3.1 4.1)" # a number of other elipsoids are supported distance.VincentyDistance.ELLIPSOID = ...


13

Is this what you are looking for? select distinct SP_GEOMETRY.STSrid from dbo.MYTABLE This will give you a table with the different SRID's used in the table dbo.MYTABLE


13

It's been a while since I used POSTGIS srids but if they are just EPSG codes then you can use http://prj2epsg.org/search to look them up from (broken) ESRI.prj files.


12

The first step to determining the correct projection of any layer, is to find the projection information, if any, that came with your layer. In the case of a Shapefile, like what you downloaded from Census.gov, that information is contained in a .prj file, short for Projection. Here are the contents of the projection file from the census data: ...


9

Taking a look at the source code of PostGIS I found out how it parses SRIDs. Here is the correct way to specify the SRID in GeoJSON. The GeoJSON specification says that the coordinates of a polygon are an array of line strings. Therefore I had to wrap them with additional brackets. { "type":"Polygon", "coordinates": [ [ ...


8

Borrowing the idea from @iant, here is a PL/Python3 module that will look up the EPSG SRID integer codes from a PRJ file using the http://prj2epsg.org web service. First, install PL/Python3: CREATE LANGUAGE plpython3u; an now add the SQL function, which has code written for Python 3: CREATE OR REPLACE FUNCTION prj2epsg(prj_file text) RETURNS integer AS ...


8

Well known definitions are in the gdal/data directory. You can browse the current directory source online: http://trac.osgeo.org/gdal/browser/trunk/gdal/data. Look at the gcs.csv and pcs.csv files.


8

When you specify a geometry without an SRID, it is actually 0 (or -1 for version < 2): SELECT ST_SRID('POINT(-122.334172173172 46.602634395263560)'::geometry); st_srid --------- 0 So when you use this geometry with another one with SRID=4326, it is mixing 0 and 4326. This is usually a useful error, if the spatial references are truly different. ...


7

I would note that if you have curl support in your GDAL build (a very common configuration), you can simply give the spatialreference.org URL for the SRS and it will fetch what it needs and dereference it appropriately. -a_srs http://spatialreference.org/ref/epsg/4326/ -t_srs http://spatialreference.org/ref/epsg/26915


7

Because spatialreference.org pre-dates PostGIS 2.0, when the SRID key limitation was added No problems with your workaround sr.org is basically defunct, there's no active maintainers, you can file a ticket for posterity and the next maintainers at http://trac.osgeo.org/metacrs/ under the sr.org category. The '9' was probably tacked on to avoid conflicting ...


6

Following on from the answer given by @atlefren, an SRID usually is made of two components, an "authority" and an identifier. The authority is just the name of the organization that catalogues the identifiers. The most common authority you'll see is EPSG, which sands for the "European Petroleum Survey Group", and they have a comprehensive database of ...


6

Wikipedia: A Spatial Reference System Identifier (SRID) is a unique value used to unambiguously identify projected, unprojected, and local spatial coordinate system definitions. In other words, a system of indentifiers for spatial reference system, so that i can tell a GIS application (like postGIS) that my data is in WGS84 Geographic coordinates by ...


6

Assuming your areas of interest are rather small compared to the globe, you could set up a custom transverse mercator projection. You have to know the geographic coordinates lat_0 and lon_0 of the origin of your CRS, and the direction of x and y axis: +proj=tmerc +lat_0=51.4 +lon_0=7 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ...


6

Usually, the unit is given for each CRS inside its documentation, so you can find it directly in the CRS information, for example : UNIT["metre",1,AUTHORITY["EPSG","9001"] UNIT["degree",0.01745329251994328, AUTHORITY["EPSG","9122"]] if you don't find the information on your system (, you can check on spatialreference.org Be aware that sometimes ...


5

At a guess, your point should be about 5.5km southeast of Bad Reichenhall right? If so, the problem you have is you're interpreting your input coordinates incorrectly. The clue is in the source projection's name: LAEA which stands for Lambert Azimuthal Equal-Area, which is a projection that uses linear units (metres in this case) rather than angular units. ...


5

To get the coordinate system of your table use the following: SELECT ST_SRID(the_geom) FROM your_table_name LIMIT 1; For your second question, I am not sure if EPSG:4283 is by default defined in spatial_ref_sys table. In case it is not, you can use a INSERT command. This definition is from spatialreference.org: INSERT into spatial_ref_sys (srid, ...


5

There is no native way to do this in SQL Server (isn't ST_Transform a PostGIS method?). Look into something like SQL Server Spatial Tools and this post from a few weeks back. Also, you won't find any projected coordinate systems in the sys.spatial_reference_systems table as that table is only GEOGCS and used for geography datatypes.


5

You have loaded your data with the wrong SRID. 4269 is lon/lat NAD 83. 4326 is lon/lat WGS 84. They are practically the same projection, and both geographic. Judging from your coordinates, the data is actually in some planar projection, though without knowing extra information (like where you are) I can't even take an informed guess as to which one.


5

The definition of SRID 4326 is in fact IN DEGREES. ALso as it says in the ST_DWithin page: Returns true if the geometries are within the specified distance of one another. For geometry units are in those of spatial reference and For geography units are in meters and measurement is defaulted to use_spheroid=true (measure around spheroid), Since you're ...


5

Sounds like the point just isn't in the polygon. WITH pt AS ( SELECT ST_SetSRID(ST_MakePoint(-159.717,21.933), 4326) AS geom ) SELECT ST_Distance(states.geom, pt.geom) FROM states, pt WHERE states.abbr = 'HI'; And Google seems to think so too. It's close, but it's not in. https://maps.google.ca/maps?client=safari&oe=UTF-8&q=21.933N+159.717W


5

When talking about geographic locations, we usually say and use Lat-long. This has been codified in the ISO 6709 standard. When dealing with Cartesian coordinate geometry, we generally use X-Y. Many GIS systems, work with a Geographic Location as a special case of a 2 D coordinate point, where the X represents the longitude and Y represents the Latitude. ...


4

As a mix of solutions I have created a script to help me load arbitrary shapefiles into postgis. It also tries to detect the encoding of the DBF. from chardet.universaldetector import UniversalDetector import os.path import sys import dbfUtils import sys from osgeo import osr from urllib import urlencode from urllib2 import urlopen import json shp_file = ...


4

You could also use Shapely's length property, i.e.: from shapely.wkt import loads l=loads('LINESTRING(3.0 4.0, 3.1 4.1)') print l.length


4

Use latitude and longitude and the great circle distance, not a map projection.


4

From Postgis doc: The syntax is find_srid(, , ) and the function returns the integer SRID of the specified column by searching through the GEOMETRY_COLUMNS table. If the geometry column has not been properly added with the AddGeometryColumns() function, this function will not work either. So you shoud have a row in GEOMETRY_COLUMNS table for ...


4

Postgis, spatialite and Qgis mainly use GDAL/Proj definitions with EPSG codes as ID for CRS. You find a lot of them at spatialreference.org, but that database is a bit outdated. For Dutch RD, there is EPSG:28991 Amersfoort/RD Old EPSG:28992 Amersfoort/RD New Oracle used their own SRID up to release 10.1, and switched to EPSG codes as of release 10.2 ...


4

Are you sure those are the correct coordinates? On Google Maps, the best way to grab the coordinates is to click on the small "Maps Labs" link and enable "LatLng Marker". Then right-click on both locations, and click "drop LatLng marker". This will show: -73.9740, 40.7638 and -73.9845, 40.7490 (I've rearranged to be in longitude, latitude order to ...


4

What's happening is that the data you are trying to insert does not have an SRID assigned. To assign one, try wrapping the inserted geometry in your insert statement with ST_SetSRID(). E.g., INSERT INTO public.borne (num_borne, shape_borne) (SELECT num_borne, ST_SetSRID(shape_borne, 26191) FROM public.sometable); or INSERT INTO public.borne ...


4

ST_GeomFromText('POINT(22.256 39.569)') is not going to give you a geometry in EPSG:4326. From the documentation: There are 2 variants of ST_GeomFromText function, the first takes no SRID and returns a geometry with no defined spatial reference system. The second takes a spatial reference id as the second argument and returns an ST_Geometry that ...



Only top voted, non community-wiki answers of a minimum length are eligible