How to create polygon (Projected NAD83) with specific length and width, but no X,Y points*
I totally agree with Dan.
It can be done, but a little bit more info would be appreciated. To create a rectangle you will need coordinates. You can create them randomly but you will still need some range of valid values. See below a sample script that will create a number of rectangles. In this case I took the projected coordinate system with NAD 1983 as datum and defined an extent for values values for xmin and ymin of the rectangles to be created:
<SPAN class="keyword token">def</SPAN> <SPAN class="token function">main</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">import</SPAN> arcpy <SPAN class="keyword token">import</SPAN> random arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>overwriteOutput <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">True</SPAN> <SPAN class="comment token"># some settings</SPAN> fc_out <SPAN class="operator token">=</SPAN> r<SPAN class="string token">'C:\GeoNet\RandomRectangle\test2.shp'</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">10000</SPAN> height <SPAN class="operator token">=</SPAN> <SPAN class="number token">5000</SPAN> xy_extent <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Extent<SPAN class="punctuation token">(</SPAN><SPAN class="number token">2048900</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">549400</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">2094700</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">573600</SPAN><SPAN class="punctuation token">)</SPAN> number_of_rectangles <SPAN class="operator token">=</SPAN> <SPAN class="number token">25</SPAN> <SPAN class="comment token"># NAD_1983_2011_StatePlane_California_V_FIPS_0405</SPAN> sr_pcs <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>SpatialReference<SPAN class="punctuation token">(</SPAN><SPAN class="number token">103001</SPAN><SPAN class="punctuation token">)</SPAN> feats <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">for</SPAN> i <SPAN class="keyword token">in</SPAN> range<SPAN class="punctuation token">(</SPAN>number_of_rectangles<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="comment token"># get a random xmin and ymin of the rectangle</SPAN> xmin <SPAN class="operator token">=</SPAN> random<SPAN class="punctuation token">.</SPAN>randrange<SPAN class="punctuation token">(</SPAN>xy_extent<SPAN class="punctuation token">.</SPAN>XMin<SPAN class="punctuation token">,</SPAN> xy_extent<SPAN class="punctuation token">.</SPAN>XMax<SPAN class="punctuation token">)</SPAN> ymin <SPAN class="operator token">=</SPAN>random<SPAN class="punctuation token">.</SPAN>randrange<SPAN class="punctuation token">(</SPAN>xy_extent<SPAN class="punctuation token">.</SPAN>YMin<SPAN class="punctuation token">,</SPAN> xy_extent<SPAN class="punctuation token">.</SPAN>YMax<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># create the rectangle</SPAN> pnts <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">[</SPAN>xmin<SPAN class="punctuation token">,</SPAN> ymin<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN>xmin<SPAN class="punctuation token">,</SPAN> ymin <SPAN class="operator token">+</SPAN> height<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN>xmin <SPAN class="operator token">+</SPAN> width<SPAN class="punctuation token">,</SPAN> ymin <SPAN class="operator token">+</SPAN> height<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN>xmin <SPAN class="operator token">+</SPAN> width<SPAN class="punctuation token">,</SPAN> ymin<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN>xmin<SPAN class="punctuation token">,</SPAN> ymin<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">]</SPAN> polygon <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Polygon<SPAN class="punctuation token">(</SPAN>arcpy<SPAN class="punctuation token">.</SPAN>Array<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN>arcpy<SPAN class="punctuation token">.</SPAN>Point<SPAN class="punctuation token">(</SPAN><SPAN class="operator token">*</SPAN>pnt<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">for</SPAN> pnt <SPAN class="keyword token">in</SPAN> pnts<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> sr_pcs<SPAN class="punctuation token">)</SPAN> feats<SPAN class="punctuation token">.</SPAN>append<SPAN class="punctuation token">(</SPAN>polygon<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># write the rectangle to the output fc</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>CopyFeatures_management<SPAN class="punctuation token">(</SPAN>feats<SPAN class="punctuation token">,</SPAN> fc_out<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">if</SPAN> __name__ <SPAN class="operator token">==</SPAN> <SPAN class="string token">'__main__'</SPAN><SPAN class="punctuation token">:</SPAN> main<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
And the result:
Could you elaborate a little more on what you are trying to achieve?
Perhaps you have other details that you could share.
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.