Last active
August 29, 2015 14:19
-
-
Save albert-decatur/36ac02166007bd880aeb to your computer and use it in GitHub Desktop.
landsat-api polar stereoscopic flip
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
select st_astext(st_transform(st_geomfromtext('POINT( 170.84215 -80.9338 )',4326),3031)); |
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
cat * |jq '.results[]|[.upperLeftCornerLongitude,.upperLeftCornerLatitude]|@csv' | sed "s:\"::g;s:,: :g;s:^:'POINT( :g;s:$: )',4326:g" | sed 's:^:ST_GeomFromText( :g;s:$: ):g;s:^:ST_Transform( :g;s:$:,3031 ):g;s:^:ST_AsText( :g;s:$: ):g;s:^:SELECT :g' | sed 's:^:COPY (:g;s:$: ) TO STDOUT;:g' | psql scratch |
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
scene=LC80231222014362LGN00; curl -s "https://api.developmentseed.org/landsat?search=${scene}" |jq '.results[]|[.upperLeftCornerLongitude,.upperLeftCornerLatitude]|@csv' | sed 's:"::g;s:,: :g;s:^:POINT( :g;s:$: ):g' |
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
outdir=out/; a="'";db=scratch; antarctic_scenes=$( echo "copy ( select path,row from wrs2_asc_desc where row >= 120 and row <= 122 ) to stdout with csv header;" | psql $db | sed '1d' ); echo "$antarctic_scenes" | parallel --gnu 'landsat search -p {} -l 1 2>/dev/null | grep sceneID | grep -oE "LC8.*$" | sed "s:\",\s*$::g" | xargs -I :: curl -s "https://api.developmentseed.org/landsat?search=::" | jq '$a'.results[]|[.lowerLeftCornerLongitude,.lowerLeftCornerLatitude,"",.lowerRightCornerLongitude,.lowerRightCornerLatitude,"",.upperRightCornerLongitude,.upperRightCornerLatitude,"",.upperLeftCornerLongitude,.upperLeftCornerLatitude,"",.lowerLeftCornerLongitude,.lowerLeftCornerLatitude]|@csv'$a' | sed '$a's:\\::g;s:"::g;s:\(,\{2\}\):|:g;s:,: :g;s:|:,:g;s:^:POLYGON((:g;s:$:)):g'$a' | wellknown > '$outdir'/$( echo {} | sed "s:,::g" ).geojson' |
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
# get wkt points one per line | |
db=scratch; antarctic_scenes=$( echo "cop( select path,row from wrs2_asc_desc where row >= 120 and row <= 122 ) to stdout with csv header;" | psql $db | sed '1d' ); echo "$antarctic_scenes" | parallel --gnu 'landsat search -p {} -l 1 2>/dev/null | grep sceneID | grep -oE "LC8.*$" | sed "s:\",\s*$::g" | xargs -I :: curl -s "https://api.developmentseed.org/landsat?search=::" | grep -i browse | grep http | grep -oE "http.*\",$" | sed "s:\",$::g"' | |
# get wkt points as single multipoint | |
cat * |jq '.results[]|[.upperLeftCornerLongitude,.upperLeftCornerLatitude]|@csv' | sed "s:\"::g;s:,: :g;s:^:'POINT( :g;s:$: )',4326:g" | sed 's:^:ST_GeomFromText( :g;s:$: ):g;s:^:ST_Transform( :g;s:$:,3031 ):g;s:^:ST_AsText( :g;s:$: ):g;s:^:SELECT :g' | sed 's:^:COPY (:g;s:$: ) TO STDOUT;:g' | psql scratch | sed 's:^POINT::g' | tr '\n' ',' | sed 's:,$::g' | sed 's:^:MULTIPOINT (:g;s:$: ):g' | clipboard |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
great example scene with topographical features visible:
LC80231222014362LGN00
landsat-api corners:
MTL corners:
CORNER_UL_LAT_PRODUCT = -83.13193
CORNER_UL_LON_PRODUCT = 171.66491
CORNER_UR_LAT_PRODUCT = -82.51633
CORNER_UR_LON_PRODUCT = 155.21012
CORNER_LL_LAT_PRODUCT = -80.99184
CORNER_LL_LON_PRODUCT = 173.65981
CORNER_LR_LAT_PRODUCT = -80.51567
CORNER_LR_LON_PRODUCT = 160.69660
CORNER_UL_PROJECTION_X_PRODUCT = 108300.000
CORNER_UL_PROJECTION_Y_PRODUCT = -739200.000
CORNER_UR_PROJECTION_X_PRODUCT = 341400.000
CORNER_UR_PROJECTION_Y_PRODUCT = -739200.000
CORNER_LL_PROJECTION_X_PRODUCT = 108300.000
CORNER_LL_PROJECTION_Y_PRODUCT = -974700.000
CORNER_LR_PROJECTION_X_PRODUCT = 341400.000
CORNER_LR_PROJECTION_Y_PRODUCT = -974700.000