<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Python script, cutting area with gdal_translate using Spyder in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-script-cutting-area-with-gdal-translate/m-p/545393#M42541</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What part do you have a problem with (I can't help with any GDAL stuff unfortunately).&lt;/P&gt;&lt;P&gt;I would however:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.Create a python list or dictionary of your Cities as a Key, and the WGS84 Lat Long as a value.&lt;/P&gt;&lt;P&gt;2. Run these through GDAL translate to get the projected coordinates&lt;/P&gt;&lt;P&gt;3. Do some simple maths to get your UL/BR coordinates for each city 30km square.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MyDictionary = {"Lublin" : [290004 370001, 320004 34001], "Frampol" : [ ...&lt;/P&gt;&lt;P&gt;workspace = r"C:\\.."&lt;/P&gt;&lt;P&gt;Input = "Lublin"&lt;/P&gt;&lt;P&gt;#create output path&lt;/P&gt;&lt;P&gt;outpath = Input+".tif"&lt;/P&gt;&lt;P&gt;outpath = os.path.join(workspace, outpath)&lt;/P&gt;&lt;P&gt;GDAL_function(MyDictionary[Input], outpath)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 07 Jun 2020 19:05:42 GMT</pubDate>
    <dc:creator>DavidPike</dc:creator>
    <dc:date>2020-06-07T19:05:42Z</dc:date>
    <item>
      <title>Python script, cutting area with gdal_translate using Spyder</title>
      <link>https://community.esri.com/t5/python-questions/python-script-cutting-area-with-gdal-translate/m-p/545392#M42540</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P class="" style="color: #1a1a1b; background-color: #ffffff; border: 0px; font-size: 14px; padding: 0px 0px 0.25em;"&gt;I am attaching a file&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="border: 0px; font-weight: bold; font-size: inherit;"&gt;&lt;STRONG class=""&gt;lubelskie.tiff&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(DEM in the reference system EPSG:2180, for one of the counties in Poland).&lt;/P&gt;&lt;P class="" style="color: #1a1a1b; background-color: #ffffff; border: 0px; font-size: 14px; padding: 0.8em 0px 0.25em;"&gt;I need to write a python script, in which the user is asked to enter the name of the town belonging to that county (for example cities&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="border: 0px; font-weight: bold; font-size: inherit;"&gt;&lt;STRONG class=""&gt;Lublin&lt;/STRONG&gt;&lt;/SPAN&gt;,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="border: 0px; font-weight: bold; font-size: inherit;"&gt;&lt;STRONG class=""&gt;Frampol&lt;/STRONG&gt;&lt;/SPAN&gt;,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="border: 0px; font-weight: bold; font-size: inherit;"&gt;&lt;STRONG class=""&gt;Parczew&lt;/STRONG&gt;&lt;/SPAN&gt;), and this script then cuts out from the lubelskie.tiff file a square with a side of 30 kilometers, whose center is in the center of the entered town. The cut area is to be saved to the city.tiff file, where the word "city" is to be replaced by the actual city name.&lt;/P&gt;&lt;P class="" style="color: #1a1a1b; background-color: #ffffff; border: 0px; font-size: 14px; padding: 0.8em 0px 0.25em;"&gt;You can use the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="border: 0px; font-weight: inherit; font-size: inherit;"&gt;&lt;EM class=""&gt;ogrinfo&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;command (from the attached file&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="border: 0px; font-weight: bold; font-size: inherit;"&gt;&lt;STRONG class=""&gt;zad_07.py&lt;/STRONG&gt;&lt;/SPAN&gt;) to find the coordinates of the city (in the WGS84 coordinate system (longitude, latitude)), and the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="border: 0px; font-weight: inherit; font-size: inherit;"&gt;&lt;EM class=""&gt;gdaltransform&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;command (from the attached file&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="border: 0px; font-weight: bold; font-size: inherit;"&gt;&lt;STRONG class=""&gt;zad_08.py&lt;/STRONG&gt;&lt;/SPAN&gt;) to convert the WGS84 coordinates to coordinates EPSG: 2180. In addition, you must add gdal_translate command to cut the area.&lt;/P&gt;&lt;P class="" style="color: #1a1a1b; background-color: #ffffff; border: 0px; font-size: 14px; padding: 0.8em 0px 0.25em;"&gt;The&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="border: 0px; font-weight: inherit; font-size: inherit;"&gt;&lt;EM class=""&gt;gdal_translate&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;command can probably be used in the following way:&lt;/P&gt;&lt;P class="" style="color: #1a1a1b; background-color: #ffffff; border: 0px; font-size: 14px; padding: 0.8em 0px 0.25em;"&gt;gdal_translate -projwin ulx uly lrx lry lubelskie.tif city.tif&lt;/P&gt;&lt;P class="" style="color: #1a1a1b; background-color: #ffffff; border: 0px; font-size: 14px; padding: 0.8em 0px 0.25em;"&gt;where ulx, uly, lrx, lry are respectively: the x coordinate of the upper left vertex, y coordinate of the upper left vertex, the x coordinate of the bottom right vertex, the y coordinate of the lower right vertex of the cut out fragment.&lt;/P&gt;&lt;P class="" style="color: #1a1a1b; background-color: #ffffff; border: 0px; font-size: 14px; padding: 0.8em 0px 0.25em;"&gt;The files are packed here:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="border: 0px; font-weight: bold; font-size: inherit;"&gt;&lt;STRONG class=""&gt;lubelskie.tiff, zad_7.py, zad_8.py&lt;/STRONG&gt;&lt;/SPAN&gt;.&lt;/P&gt;&lt;P class="" style="color: #1a1a1b; background-color: #ffffff; border: 0px; font-size: 14px; padding: 0.8em 0px 0.25em;"&gt;&lt;A href="https://www97.zippyshare.com/v/zyQXpmmx/file.html" rel="noopener nofollow ugc" style="color: var(--newcommunitytheme-linktext); border: 0px; text-decoration: underline;" target="_blank"&gt;https://www97.zippyshare.com/v/zyQXpmmx/file.html&lt;/A&gt;&lt;/P&gt;&lt;P class="" style="color: #1a1a1b; background-color: #ffffff; border: 0px; font-size: 14px; padding: 0.8em 0px 0px;"&gt;Can you help me write this script? I am stuck and need help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 07 Jun 2020 14:07:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-cutting-area-with-gdal-translate/m-p/545392#M42540</guid>
      <dc:creator>RafaelMichael</dc:creator>
      <dc:date>2020-06-07T14:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: Python script, cutting area with gdal_translate using Spyder</title>
      <link>https://community.esri.com/t5/python-questions/python-script-cutting-area-with-gdal-translate/m-p/545393#M42541</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What part do you have a problem with (I can't help with any GDAL stuff unfortunately).&lt;/P&gt;&lt;P&gt;I would however:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.Create a python list or dictionary of your Cities as a Key, and the WGS84 Lat Long as a value.&lt;/P&gt;&lt;P&gt;2. Run these through GDAL translate to get the projected coordinates&lt;/P&gt;&lt;P&gt;3. Do some simple maths to get your UL/BR coordinates for each city 30km square.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MyDictionary = {"Lublin" : [290004 370001, 320004 34001], "Frampol" : [ ...&lt;/P&gt;&lt;P&gt;workspace = r"C:\\.."&lt;/P&gt;&lt;P&gt;Input = "Lublin"&lt;/P&gt;&lt;P&gt;#create output path&lt;/P&gt;&lt;P&gt;outpath = Input+".tif"&lt;/P&gt;&lt;P&gt;outpath = os.path.join(workspace, outpath)&lt;/P&gt;&lt;P&gt;GDAL_function(MyDictionary[Input], outpath)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 07 Jun 2020 19:05:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-cutting-area-with-gdal-translate/m-p/545393#M42541</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2020-06-07T19:05:42Z</dc:date>
    </item>
  </channel>
</rss>

