ZihHong
February 22, 2024, 6:00am
1
Hi,
I have tried to write a script for batch-processing crop_production_percentile model. The API seems to have some problems.
→ 506 landcover_wgs84_bounding_box = pygeoprocessing.transform_bounding_box(
507 landcover_raster_info[‘bounding_box’],
508 landcover_raster_info[‘projection_wkt’], wgs84srs.ExportToWkt(),
509 edge_samples=11)
→ 3557 [_transform_point(
3558 p_a * v + p_b * (1 - v)) for v in numpy.linspace(
AttributeError: ‘NoneType’ object has no attribute ‘TransformPoint’
esoth
February 22, 2024, 6:46pm
2
The error suggests that your input data has an invalid or missing projection. If you attach your complete code and data, I will try to identify the problem.
ZihHong
February 23, 2024, 9:19am
3
Hi,
Thank you for the prompt and kind reply.
I’ve attached the script and data via google drive. Thank you for your kind assistance.
esoth
February 26, 2024, 7:23pm
4
@ZihHong I ran your script and got no errors. What versions of natcap.invest
, gdal
, and pygeoprocessing
are you using?
ZihHong
February 26, 2024, 10:57pm
5
Hi @esoth , I have tried two sets of versions, including:
1: natcap.invest: 3.14.1; gdal: 3.4.3; pygeoprocessing: 2.4.2
2: natcap.invest: 3.11.0; gdal: 3.1.2; pygeoprocessing: 2.3.2
They both encountered the same problem. Are there any other suggested versions?
esoth
February 27, 2024, 8:42pm
6
Those versions should be fine. I recommend sticking with 3.14.1.
Can you please try running the following code and see if it succeeds or throws an error?
from osgeo import gdal, osr
base_ref = osr.SpatialReference()
base_ref.ImportFromEPSG(3826)
target_ref = osr.SpatialReference()
target_ref.ImportFromEPSG(4326)
transformer = osr.CreateCoordinateTransformation(base_ref, target_ref)
print(transformer.TransformPoint(300000, 3000000))
This is a test case for the operation that’s causing the error: transforming from EPSG:3826 to WGS84. It seems like maybe your version of GDAL or PROJ isn’t finding the coordinate transformation.
ZihHong
February 28, 2024, 12:27am
7
Hi @esoth ,
The code showed that the transformer didn’t work. Thus, I removed the current goal and reinstalled it.
Fortunately, it works. Maybe there is some error while installing the old one.
Thank you for your kind and patient advice.
1 Like
system
Closed
March 6, 2024, 12:27am
8
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.