Created
August 4, 2023 20:41
-
-
Save jdbcode/31ea8d130f20992d214b22a6de705ffa to your computer and use it in GitHub Desktop.
js_vs_py_exports_test.ipynb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"provenance": [], | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"language_info": { | |
"name": "python" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/jdbcode/31ea8d130f20992d214b22a6de705ffa/js_vs_py_exports_test.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"id": "m0bA5g4VIHOh" | |
}, | |
"outputs": [], | |
"source": [ | |
"import ee\n", | |
"ee.Authenticate()\n", | |
"ee.Initialize()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"FAO = ee.FeatureCollection(\"FAO/GAUL/2015/level2\")\n", | |
"FAO_US = FAO.filter(ee.Filter.eq('ADM0_NAME', 'United States of America'))\n", | |
"state_bound = FAO_US.filter(ee.Filter.eq('ADM1_NAME', 'Georgia'))\n", | |
"outputGeom = state_bound.geometry().bounds()" | |
], | |
"metadata": { | |
"id": "kwWqSawSIRcD" | |
}, | |
"execution_count": 2, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"roofImage = ee.Image('projects/ee-ycheng1891/assets/shared/US_Georgia_roofImage')\n", | |
"\n", | |
"isRoof = (roofImage.eq(1)\n", | |
" .unmask(0)\n", | |
" .setDefaultProjection(**{'crs': roofImage.projection()})\n", | |
" .rename('roof'))\n", | |
"\n", | |
"isRoof10 = (isRoof.eq(1)\n", | |
" .reproject(**{'crs': roofImage.projection(), 'scale': 10})\n", | |
" .reduceResolution(**{'reducer': ee.Reducer.mean(), 'maxPixels': 65536})\n", | |
" .unmask(0))\n", | |
"\n", | |
"roofFrac100_cal = (isRoof10\n", | |
" .reproject(**{'crs': roofImage.projection(), 'scale':100})\n", | |
" .reduceResolution(**{'reducer': ee.Reducer.mean(), 'maxPixels': 65536}))" | |
], | |
"metadata": { | |
"id": "N9jr_1q-IhV9" | |
}, | |
"execution_count": 3, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"# EXPORT USING `scale` PARAMETER\n", | |
"task1 = ee.batch.Export.image.toAsset(\n", | |
" **{'image': roofFrac100_cal,\n", | |
" 'description': 'US_Georgia_roofFrac100_4326_scale_py',\n", | |
" 'assetId': 'projects/ee-jstnbraaten/assets/roofs_bug/US_Georgia_roofFrac100_4326_scale_py',\n", | |
" 'scale': 100,\n", | |
" 'crs': 'EPSG:4326',\n", | |
" 'region': outputGeom,\n", | |
" 'maxPixels': 1e13\n", | |
" })\n", | |
"\n", | |
"# EXPORT USING `crsTransform` PARAMETER\n", | |
"task2 = ee.batch.Export.image.toAsset(\n", | |
" **{'image': roofFrac100_cal,\n", | |
" 'description': 'US_Georgia_roofFrac100_4326_crsTransform_py',\n", | |
" 'assetId': 'projects/ee-jstnbraaten/assets/roofs_bug/US_Georgia_roofFrac100_4326_crsTransform_py',\n", | |
" 'crsTransform': roofFrac100_cal.projection().getInfo()['transform'],\n", | |
" 'crs': 'EPSG:4326',\n", | |
" 'region': outputGeom,\n", | |
" 'maxPixels': 1e13\n", | |
" })" | |
], | |
"metadata": { | |
"id": "L7QRkg2GI1g4" | |
}, | |
"execution_count": 4, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"task1.start()\n", | |
"task2.start()" | |
], | |
"metadata": { | |
"id": "392WNIkMJUju" | |
}, | |
"execution_count": 5, | |
"outputs": [] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment