import rastereasy
Re projection
name_im = './data/demo/sentinel.tif'
image=rastereasy.Geoimage(name_im)
image.info()
- Size of the image:
- Rows (height): 1000
- Cols (width): 1000
- Bands: 12
- Spatial resolution: 10.0 meters / degree (depending on projection system)
- Central point latitude - longitude coordinates: (7.04099599, 38.39058840)
- Driver: GTiff
- Data type: int16
- Projection system: EPSG:32637
- Nodata: -32768.0
- Given names for spectral bands:
{'1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '10': 10, '11': 11, '12': 12}
help(image.reproject)
Help on method reproject in module rastereasy.rastereasy:
reproject(projection='EPSG:3857', inplace=False, dest_name=None) method of rastereasy.rastereasy.Geoimage instance
Reproject the image to a different coordinate reference system (CRS).
This method transforms the image in-place to a new projection system, which
changes how the image's coordinates are interpreted. This can be useful for
aligning data from different sources or preparing data for specific analyses.
Parameters
----------
projection : str, optional
The target projection as an EPSG code or PROJ string.
Examples:
- "EPSG:4326": WGS84 geographic (lat/lon)
- "EPSG:3857": Web Mercator (used by web maps)
- "EPSG:32619": UTM Zone 19N
Default is "EPSG:3857" (Web Mercator).
inplace : bool, default False
If False, return a copy. Otherwise, do reprojection in place and return None.
dest_name : str, optional
Path to save the reprojected image. If None, the image is not saved.
Default is None.
Returns
-------
Geoimage
The reprojected image
Examples
--------
>>> # Reproject to WGS84 (latitude/longitude)
>>> image_reprojected = image.reproject("EPSG:4326")
>>> image_reprojected.info() # Shows new projection
>>>
>>> # Reproject to UTM Zone 17N and save
>>> image_reprojected = image.reproject("EPSG:32617", dest_name="utm.tif")
>>>
>>>
>>> # Reproject to WGS84 (latitude/longitude) and modify inplace the image
>>> image.reproject("EPSG:4326", inplace=True)
>>> image.info() # Shows new projection
>>>
>>> # Reproject to UTM Zone 17N and save
>>> image.reproject("EPSG:32617", dest_name="utm.tif", inplace=True)
Notes
-----
- Reprojection can change the pixel values due to resampling
- The dimensions of the image will typically change during reprojection
- Common projection systems include:
- EPSG:4326 - WGS84 geographic coordinates (latitude/longitude)
- EPSG:3857 - Web Mercator (used by Google Maps, OpenStreetMap)
- EPSG:326xx - UTM Zone xx North (projected coordinate system)
- EPSG:327xx - UTM Zone xx South (projected coordinate system)
Two options
Return a reprojected image (function
reproject
)Directly reproject the original image (function
reproject
withinplace=True
option)
1) Return a reprojected image
image=rastereasy.Geoimage(name_im)
print('----Original image--')
image.info()
image.colorcomp([4,3,2])
image_reprojected=image.reproject('EPSG:27700')
print('----Re projected image--')
image_reprojected.info()
image_reprojected.colorcomp([4,3,2])
----Original image--
- Size of the image:
- Rows (height): 1000
- Cols (width): 1000
- Bands: 12
- Spatial resolution: 10.0 meters / degree (depending on projection system)
- Central point latitude - longitude coordinates: (7.04099599, 38.39058840)
- Driver: GTiff
- Data type: int16
- Projection system: EPSG:32637
- Nodata: -32768.0
- Given names for spectral bands:
{'1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '10': 10, '11': 11, '12': 12}
<Figure size 640x480 with 0 Axes>

----Re projected image--
- Size of the image:
- Rows (height): 1100
- Cols (width): 1100
- Bands: 12
- Spatial resolution: 13.086847568491946 meters / degree (depending on projection system)
- Central point latitude - longitude coordinates: (7.04105390, 38.39059931)
- Driver: GTiff
- Data type: int16
- Projection system: EPSG:27700
- Nodata: -32768.0
- Given names for spectral bands:
{'1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '10': 10, '11': 11, '12': 12}
<Figure size 640x480 with 0 Axes>

2) Directly reproject to the image
image=rastereasy.Geoimage(name_im)
print('----Original image--')
image.info()
image.colorcomp([4,3,2])
print('----Re projected image--')
image.reproject('EPSG:27700', inplace=True)
image.info()
image.colorcomp([4,3,2])
----Original image--
- Size of the image:
- Rows (height): 1000
- Cols (width): 1000
- Bands: 12
- Spatial resolution: 10.0 meters / degree (depending on projection system)
- Central point latitude - longitude coordinates: (7.04099599, 38.39058840)
- Driver: GTiff
- Data type: int16
- Projection system: EPSG:32637
- Nodata: -32768.0
- Given names for spectral bands:
{'1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '10': 10, '11': 11, '12': 12}
<Figure size 640x480 with 0 Axes>

----Re projected image--
- Size of the image:
- Rows (height): 1100
- Cols (width): 1100
- Bands: 12
- Spatial resolution: 13.086847568491946 meters / degree (depending on projection system)
- Central point latitude - longitude coordinates: (7.04105390, 38.39059931)
- Driver: GTiff
- Data type: int16
- Projection system: EPSG:27700
- Nodata: -32768.0
- Given names for spectral bands:
{'1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '10': 10, '11': 11, '12': 12}
<Figure size 640x480 with 0 Axes>
