Skip to main content
deleted 28 characters in body; edited title
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

How can I set the Setting CRS of a point withusing shapely

I am working on a tool, which transfers data, including geometries, from different legacy databases to postgis.

Currently this means I have a MS-access Database, which contains point geometries, but since access does not have a geometry type, the points consist of two columns, containing numbers, like so:

lat lon
371744,668 5700069,115

During the flow of my tool, I take these coordinates with pyodbc, and use shapely to create a point. This point does not have crs since it is newly created. Now I'm trying to set it to EPSG:25832, since the postgis DB expects geometry data to be in 25832. The code below shows what is going on. In the docs I found an example, and even when I'm directly pasting the example to my code it does not work. 

What am I missing here?

def getGeomAsWKB(self, table, ids):
    tmp = self.getCoordinates(table) # tmp = list of tuples with coordinate pairs [(X,Y),(X2,Y2)...]
    geoms = []
    for coords in tmp:
        pt = Point(coords) no crs at this point, as to be expected
        srid = pyproj.CRS('EPSG:25832')
        old_srid = pyproj.CRS('EPSG:25832')
        project = pyproj.Transformer.from_crs(old_srid, srid, always_xy=True).transform
        t_pt = transform(project, pt) nothing changes
        #pt._crs = 'EPSG:25832'# i tried to set it this way, becausei did not know what else to try
        tmp_binary = wkb.dumps(t_pt)
        geoms.append(tmp_binary)
    return geoms

Just to be clear, pt and t_pt are correctly build, its just that t_pt does not contain the crs information after the transformation.

Postgis return the following error code :

Geometry SRID (0) does not match column SRID (25832)

Thank you for your advice.

How can I set the CRS of a point with shapely

I am working on a tool, which transfers data, including geometries, from different legacy databases to postgis.

Currently this means I have a MS-access Database, which contains point geometries, but since access does not have a geometry type, the points consist of two columns, containing numbers, like so:

lat lon
371744,668 5700069,115

During the flow of my tool, I take these coordinates with pyodbc, and use shapely to create a point. This point does not have crs since it is newly created. Now I'm trying to set it to EPSG:25832, since the postgis DB expects geometry data to be in 25832. The code below shows what is going on. In the docs I found an example, and even when I'm directly pasting the example to my code it does not work. What am I missing here?

def getGeomAsWKB(self, table, ids):
    tmp = self.getCoordinates(table) # tmp = list of tuples with coordinate pairs [(X,Y),(X2,Y2)...]
    geoms = []
    for coords in tmp:
        pt = Point(coords) no crs at this point, as to be expected
        srid = pyproj.CRS('EPSG:25832')
        old_srid = pyproj.CRS('EPSG:25832')
        project = pyproj.Transformer.from_crs(old_srid, srid, always_xy=True).transform
        t_pt = transform(project, pt) nothing changes
        #pt._crs = 'EPSG:25832'# i tried to set it this way, becausei did not know what else to try
        tmp_binary = wkb.dumps(t_pt)
        geoms.append(tmp_binary)
    return geoms

Just to be clear, pt and t_pt are correctly build, its just that t_pt does not contain the crs information after the transformation.

Postgis return the following error code :

Geometry SRID (0) does not match column SRID (25832)

Thank you for your advice.

Setting CRS of point using shapely

I am working on a tool, which transfers data, including geometries, from different legacy databases to postgis.

Currently this means I have a MS-access Database, which contains point geometries, but since access does not have a geometry type, the points consist of two columns, containing numbers, like so:

lat lon
371744,668 5700069,115

During the flow of my tool, I take these coordinates with pyodbc, and use shapely to create a point. This point does not have crs since it is newly created. Now I'm trying to set it to EPSG:25832, since the postgis DB expects geometry data to be in 25832. The code below shows what is going on. In the docs I found an example, and even when I'm directly pasting the example to my code it does not work. 

What am I missing here?

def getGeomAsWKB(self, table, ids):
    tmp = self.getCoordinates(table) # tmp = list of tuples with coordinate pairs [(X,Y),(X2,Y2)...]
    geoms = []
    for coords in tmp:
        pt = Point(coords) no crs at this point, as to be expected
        srid = pyproj.CRS('EPSG:25832')
        old_srid = pyproj.CRS('EPSG:25832')
        project = pyproj.Transformer.from_crs(old_srid, srid, always_xy=True).transform
        t_pt = transform(project, pt) nothing changes
        #pt._crs = 'EPSG:25832'# i tried to set it this way, becausei did not know what else to try
        tmp_binary = wkb.dumps(t_pt)
        geoms.append(tmp_binary)
    return geoms

Just to be clear, pt and t_pt are correctly build, its just that t_pt does not contain the crs information after the transformation.

Postgis return the following error code :

Geometry SRID (0) does not match column SRID (25832)

Improved grammar
Source Link
Hornbydd
  • 44.6k
  • 5
  • 42
  • 84

How can iI set the CRS of a point with shapely

ImI am working on a tool, which transfers data, including geometries, from different legacy databases to postgis.

Currently this means iI have a MS-access Database, which contains point geometries, but since access does not have a geometry type, the points consist of two columns, containing numbers, like so:

lat lon
371744,668 5700069,115

During the flow of my tool, iI take these coordinates with pyodbc, and use shapely to create a point. This point does not have crs since it is newly created. Now imI'm trying to set it to EPSG:25832, since the postgis DB expects geometry data to be in 25832. The code below shows what is going on. In the docs iI found an example, and even when i'mI'm directly pasting the example to my code it does not work. What am iI missing here?

def getGeomAsWKB(self, table, ids):
    tmp = self.getCoordinates(table) # tmp = list of tuples with coordinate pairs [(X,Y),(X2,Y2)...]
    geoms = []
    for coords in tmp:
        pt = Point(coords) no crs at this point, as to be expected
        srid = pyproj.CRS('EPSG:25832')
        old_srid = pyproj.CRS('EPSG:25832')
        project = pyproj.Transformer.from_crs(old_srid, srid, always_xy=True).transform
        t_pt = transform(project, pt) nothing changes
        #pt._crs = 'EPSG:25832'# i tried to set it this way, becausei did not know what else to try
        tmp_binary = wkb.dumps(t_pt)
        geoms.append(tmp_binary)
    return geoms

Just to be clear, pt and t_pt are correctly build, its just that t_pt does not contain the crs information after the transformation.

Postgis return the following error code :

Geometry SRID (0) does not match column SRID (25832)

Thank you for your advice.

How can i set the CRS of a point with shapely

Im working on a tool, which transfers data, including geometries, from different legacy databases to postgis.

Currently this means i have a MS-access Database, which contains point geometries, but since access does not have a geometry type, the points consist of two columns, containing numbers, like so:

lat lon
371744,668 5700069,115

During the flow of my tool, i take these coordinates with pyodbc, and use shapely to create a point. This point does not have crs since it is newly created. Now im trying to set it to EPSG:25832, since the postgis DB expects geometry data to be in 25832. The code below shows what is going on. In the docs i found an example, and even when i'm directly pasting the example to my code it does not work. What am i missing here?

def getGeomAsWKB(self, table, ids):
    tmp = self.getCoordinates(table) # tmp = list of tuples with coordinate pairs [(X,Y),(X2,Y2)...]
    geoms = []
    for coords in tmp:
        pt = Point(coords) no crs at this point, as to be expected
        srid = pyproj.CRS('EPSG:25832')
        old_srid = pyproj.CRS('EPSG:25832')
        project = pyproj.Transformer.from_crs(old_srid, srid, always_xy=True).transform
        t_pt = transform(project, pt) nothing changes
        #pt._crs = 'EPSG:25832'# i tried to set it this way, becausei did not know what else to try
        tmp_binary = wkb.dumps(t_pt)
        geoms.append(tmp_binary)
    return geoms

Just to be clear, pt and t_pt are correctly build, its just that t_pt does not contain the crs information after the transformation.

Postgis return the following error code :

Geometry SRID (0) does not match column SRID (25832)

Thank you for your advice.

How can I set the CRS of a point with shapely

I am working on a tool, which transfers data, including geometries, from different legacy databases to postgis.

Currently this means I have a MS-access Database, which contains point geometries, but since access does not have a geometry type, the points consist of two columns, containing numbers, like so:

lat lon
371744,668 5700069,115

During the flow of my tool, I take these coordinates with pyodbc, and use shapely to create a point. This point does not have crs since it is newly created. Now I'm trying to set it to EPSG:25832, since the postgis DB expects geometry data to be in 25832. The code below shows what is going on. In the docs I found an example, and even when I'm directly pasting the example to my code it does not work. What am I missing here?

def getGeomAsWKB(self, table, ids):
    tmp = self.getCoordinates(table) # tmp = list of tuples with coordinate pairs [(X,Y),(X2,Y2)...]
    geoms = []
    for coords in tmp:
        pt = Point(coords) no crs at this point, as to be expected
        srid = pyproj.CRS('EPSG:25832')
        old_srid = pyproj.CRS('EPSG:25832')
        project = pyproj.Transformer.from_crs(old_srid, srid, always_xy=True).transform
        t_pt = transform(project, pt) nothing changes
        #pt._crs = 'EPSG:25832'# i tried to set it this way, becausei did not know what else to try
        tmp_binary = wkb.dumps(t_pt)
        geoms.append(tmp_binary)
    return geoms

Just to be clear, pt and t_pt are correctly build, its just that t_pt does not contain the crs information after the transformation.

Postgis return the following error code :

Geometry SRID (0) does not match column SRID (25832)

Thank you for your advice.

added 101 characters in body
Source Link
jdoe
  • 132
  • 1
  • 1
  • 7

Im working on a tool, which transfers data, including geometries, from different legacy databases to postgis.

Currently this means i have a MS-access Database, which contains point geometries, but since access does not have a geometry type, the points consist of two columns, containing numbers, like so:

lat lon
371744,668 5700069,115

During the flow of my tool, i take these coordinates with pyodbc, and use shapely to create a point. This point does not have crs since it is newly created. Now im trying to set it to EPSG:25832, since the postgis DB expects geometry data to be in 25832. The code below shows what is going on. In the docs i found an example, and even when i'm directly pasting the example to my code it does not work. What am i missing here?

def getGeomAsWKB(self, table, ids):
    tmp = self.getCoordinates(table) # tmp = list of tuples with coordinate pairs [(X,Y),(X2,Y2)...]
    geoms = []
    for coords in tmp:
        pt = Point(coords) no crs at this point, as to be expected
        srid = pyproj.CRS('EPSG:25832')
        old_srid = pyproj.CRS('EPSG:25832')
        project = pyproj.Transformer.from_crs(old_srid, srid, always_xy=True).transform
        t_pt = transform(project, pt) nothing changes
        #pt._crs = 'EPSG:25832'# i tried to set it this way, becausei did not know what else to try
        tmp_binary = wkb.dumps(t_pt)
        geoms.append(tmp_binary)
    return geoms

Just to be clear, pt and t_pt are correctly build, its just that t_pt does not contain the crs information after the transformation.

Postgis return the following error code :

Geometry SRID (0) does not match column SRID (25832)

Thank you for your advice.

Im working on a tool, which transfers data, including geometries, from different legacy databases to postgis.

Currently this means i have a MS-access Database, which contains point geometries, but since access does not have a geometry type, the points consist of two columns, containing numbers, like so:

lat lon
371744,668 5700069,115

During the flow of my tool, i take these coordinates with pyodbc, and use shapely to create a point. This point does not have crs since it is newly created. Now im trying to set it to EPSG:25832, since the postgis DB expects geometry data to be in 25832. The code below shows what is going on. In the docs i found an example, and even when i'm directly pasting the example to my code it does not work. What am i missing here?

def getGeomAsWKB(self, table, ids):
    tmp = self.getCoordinates(table) # tmp = list of tuples with coordinate pairs [(X,Y),(X2,Y2)...]
    geoms = []
    for coords in tmp:
        pt = Point(coords) no crs at this point, as to be expected
        srid = pyproj.CRS('EPSG:25832')
        old_srid = pyproj.CRS('EPSG:25832')
        project = pyproj.Transformer.from_crs(old_srid, srid, always_xy=True).transform
        t_pt = transform(project, pt) nothing changes
        #pt._crs = 'EPSG:25832'# i tried to set it this way, becausei did not know what else to try
        tmp_binary = wkb.dumps(t_pt)
        geoms.append(tmp_binary)
    return geoms

Just to be clear, pt and t_pt are correctly build, its just that t_pt does not contain the crs information after the transformation.

Thank you for your advice.

Im working on a tool, which transfers data, including geometries, from different legacy databases to postgis.

Currently this means i have a MS-access Database, which contains point geometries, but since access does not have a geometry type, the points consist of two columns, containing numbers, like so:

lat lon
371744,668 5700069,115

During the flow of my tool, i take these coordinates with pyodbc, and use shapely to create a point. This point does not have crs since it is newly created. Now im trying to set it to EPSG:25832, since the postgis DB expects geometry data to be in 25832. The code below shows what is going on. In the docs i found an example, and even when i'm directly pasting the example to my code it does not work. What am i missing here?

def getGeomAsWKB(self, table, ids):
    tmp = self.getCoordinates(table) # tmp = list of tuples with coordinate pairs [(X,Y),(X2,Y2)...]
    geoms = []
    for coords in tmp:
        pt = Point(coords) no crs at this point, as to be expected
        srid = pyproj.CRS('EPSG:25832')
        old_srid = pyproj.CRS('EPSG:25832')
        project = pyproj.Transformer.from_crs(old_srid, srid, always_xy=True).transform
        t_pt = transform(project, pt) nothing changes
        #pt._crs = 'EPSG:25832'# i tried to set it this way, becausei did not know what else to try
        tmp_binary = wkb.dumps(t_pt)
        geoms.append(tmp_binary)
    return geoms

Just to be clear, pt and t_pt are correctly build, its just that t_pt does not contain the crs information after the transformation.

Postgis return the following error code :

Geometry SRID (0) does not match column SRID (25832)

Thank you for your advice.

Source Link
jdoe
  • 132
  • 1
  • 1
  • 7
Loading