Batch processing for Crop Production: Percentile

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’

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.

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.

@ZihHong I ran your script and got no errors. What versions of natcap.invest, gdal, and pygeoprocessing are you using?

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?

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.

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

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.